﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Common;

public class RoomRequest : BaseRequest
{

    private RoomPanel roomPanel;

    public override void Awake()
    {
        requestCode = RequestCode.Room;
        actionCode = ActionCode.ListRoom;
        roomPanel = GetComponent<RoomPanel>();
        base.Awake();
    }

    public override void SendRequest()
    {
        base.SendRequest("r");//r 无实际意义
    }

    public override void OnResponse(string data)
    {
        if (data == "0")
            return;
        List<UserData> userList = new List<UserData>();
        string[] roomArray = data.Split('|');
        foreach (string ud in roomArray)
        {
            string[] strs = ud.Split(',');
            UserData user = new UserData(strs[0], int.Parse(strs[1]), int.Parse(strs[2]));
            userList.Add(user);
        }
        roomPanel.LoadRoomItemSync(userList);
    }
}
